<?php

namespace app\api\controller;



/**
 * 消息管理
 * Class User
 * @package app\api
 */
class Msg extends \think\Controller
{

    public function index()
    {
        $param = input("param.");
        $timestamp = $_GET['timestamp'];
        $nonce = $_GET['nonce'];
        $token = 'lingmeng@123'; //要和上面配置的token令牌一样
        $signature = $_GET['signature'];
        $echostr = $_GET['echostr'];
        $array = array($timestamp, $nonce, $token);
        sort($array);
        $tmpstr = implode('', $array);
        $tmpstr = sha1($tmpstr);
        //如果是第一次访问验证token 否则是接受事件是否关注
        if ($tmpstr == $signature && $echostr) {
            echo $echostr;
            file_put_contents("code.log", $echostr);
            exit;
        } else {
            //发送消息
            $this->responseMsg();
        }
    }



}
